package cn.fjssj.demo02.service.impl;

import cn.fjssj.demo02.domain.ExcelTaskEntity;
import cn.fjssj.demo02.enums.TaskHandleStatus;
import cn.fjssj.demo02.mapper.ExcelTaskMapper;
import cn.fjssj.demo02.service.ExcelTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ExcelTaskServiceImpl extends ServiceImpl<ExcelTaskMapper, ExcelTaskEntity> implements ExcelTaskService {
    // 变更任务状态
    @Override
    public void updateStatus(Long taskId, TaskHandleStatus status) {
        ExcelTaskEntity et = ExcelTaskEntity.builder()
                .taskId(taskId)
                .handleStatus(status.getCode())
                .updateTime(new Date())
                .build();
        boolean b = this.updateById(et);
        if (!b) {
            throw new RuntimeException("更新任务状态失败");
        }
    }
}
